package cn.cheln.explorer.ds.database;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import cn.cheln.explorer.beans.FileUtil;
import cn.cheln.explorer.ds.MediaArgs;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MimeSrc
{
  public static final String SIZE_Empty = "0 B";
  public static Map<String, Category> categoryRepository = new HashMap();

  public static void closeCursor(CursorCategory paramCursorCategory)
  {
    if ((paramCursorCategory == null) || (paramCursorCategory.countCursor == null))
      return;
    if (!(paramCursorCategory.countCursor.isClosed()))
      paramCursorCategory.countCursor.close();
    paramCursorCategory.countCursor = null;
  }

  public static void deleAllEmptyPathData(Context paramContext)
  {
    try
    {
      deleAllEmptyPathDataFromDB(paramContext, MediaArgs.AudioUri);
      deleAllEmptyPathDataFromDB(paramContext, MediaArgs.ImageUri);
      deleAllEmptyPathDataFromDB(paramContext, MediaArgs.VideoUri);
      deleAllEmptyPathDataFromDB(paramContext, MediaArgs.otherUri);
      deleAllEmptyPathDataFromDB(paramContext, MediaArgs.dirUri);
      return;
    }
    catch (Exception localException)
    {
    }
  }

  public static void deleAllEmptyPathDataFromDB(Context paramContext, Uri paramUri)
  {
    try
    {
      paramContext.getContentResolver().delete(paramUri, "_data is null or _data like ''", null);
      return;
    }
    catch (Exception localException)
    {
      if (!(localException.getMessage().contains("Unknown URI")));
    }
  }

  public static Map<String, Category> getCategoryRepository()
  {
    return categoryRepository;
  }

  public static Category getEmptyCategory(Context paramContext, String paramString, Drawable paramDrawable)
  {
    CategoryInfo localCategoryInfo = new CategoryInfo();
    localCategoryInfo.size = "0 B";
    localCategoryInfo.displayName = paramString;
    localCategoryInfo.dIcon = paramDrawable;
    Category localCategory = new Category();
    localCategory.categoryInfo = localCategoryInfo;
    return localCategory;
  }

  public static Map<String, Category> initWholeCategories(Context paramContext, String paramString, List<CategoryInfo> paramList)
  {
    categoryRepository = new HashMap();
    makeMediaCursorCategory(paramString, paramList, new CategoryInfo("audio", paramContext.getString(2131034153), paramContext.getResources().getDrawable(2130837547)), MediaArgs.AudioUri, paramContext);
    makeMediaCursorCategory(paramString, paramList, new CategoryInfo("image", paramContext.getString(2131034155), paramContext.getResources().getDrawable(2130837549)), MediaArgs.ImageUri, paramContext);
    makeMediaCursorCategory(paramString, paramList, new CategoryInfo("video", paramContext.getString(2131034154), paramContext.getResources().getDrawable(2130837582)), MediaArgs.VideoUri, paramContext);
    makeMediaCursorCategory(paramString, paramList, new CategoryInfo("doc", paramContext.getString(2131034156), paramContext.getResources().getDrawable(2130837517)), MediaArgs.otherUri, paramContext);
    makeMediaCursorCategory(paramString, paramList, new CategoryInfo("apk", paramContext.getString(2131034157), paramContext.getResources().getDrawable(2130837505)), MediaArgs.otherUri, paramContext);
    return categoryRepository;
  }

  private static void makeMediaCursorCategory(String paramString, List<CategoryInfo> paramList, CategoryInfo paramCategoryInfo, Uri paramUri, Context paramContext)
    throws Resources.NotFoundException
  {
    CursorCategory localCursorCategory = new CursorCategory();
    localCursorCategory.categoryInfo = paramCategoryInfo;
    localCursorCategory.uri = paramUri;
    categoryRepository.put(paramCategoryInfo.categorySign, localCursorCategory);
    if (((paramString != null) && (!(paramString.equals(paramCategoryInfo.categorySign)))) || (!(categoryRepository.containsKey(paramString))))
      return;
    paramList.add(localCursorCategory.categoryInfo);
  }

  private static void putCategory(CategoryInfo paramCategoryInfo)
  {
    Category localCategory = new Category();
    localCategory.categoryInfo = paramCategoryInfo;
    categoryRepository.put(paramCategoryInfo.categorySign, localCategory);
  }

  public static void queryDBCategories(CategoryInfo paramCategoryInfo, CursorCategory paramCursorCategory, Context paramContext, Uri paramUri)
  {
  }

  public static void recountCategoryNum(Context paramContext)
  {
    int i;
    int j;
    do
    {
      Category localCategory;
      CursorCategory localCursorCategory;
      try
      {
        deleAllEmptyPathData(paramContext);
        Category[] arrayOfCategory = new Category[categoryRepository.values().size()];
        categoryRepository.values().toArray(arrayOfCategory);
        i = arrayOfCategory.length;
        j = 0;
        break label255:
        localCategory = arrayOfCategory[j];
        if (!(localCategory instanceof CursorCategory))
          break label252;
        localCursorCategory = (CursorCategory)localCategory;
        closeCursor(localCursorCategory);
        localCursorCategory.countCursor = MediaArgs.search(paramContext, localCursorCategory.uri, localCursorCategory.categoryInfo, " count(distinct _data) , sum(_size) ", "");
        if ((localCursorCategory.countCursor == null) || (localCursorCategory.countCursor.getCount() == 0))
        {
          ((CursorCategory)localCategory).categoryInfo.count = "0";
          return;
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return;
      }
      if (localCursorCategory.countCursor != null)
      {
        localCursorCategory.countCursor.moveToFirst();
        ((CursorCategory)localCategory).categoryInfo.count = localCursorCategory.countCursor.getInt(0);
        ((CursorCategory)localCategory).categoryInfo.size = FileUtil.formatSize((float)localCursorCategory.countCursor.getLong(1));
        ((CursorCategory)localCategory).categoryInfo.length = Float.valueOf(Long.valueOf(localCursorCategory.countCursor.getLong(1)).floatValue());
      }
      closeCursor(localCursorCategory);
      label252: label255: ++j;
    }
    while (j < i);
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     cn.cheln.explorer.ds.database.MimeSrc
 * JD-Core Version:    0.5.2
 */